import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import '@/assets/css/global.css'
import Tabletree from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import nProgress from 'nprogress'
Vue.use(VueQuillEditor/* { default global options } */)
Vue.config.productionTip = false
Vue.prototype.$http = axios
Vue.component('table-tree', Tabletree)
axios.interceptors.request.use(config => {
  nProgress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
axios.interceptors.response.use(config => {
  nProgress.done()
  return config
})
axios.defaults.baseURL = 'https://lianghj.top:8888/api/private/v1/'

Vue.filter('getDate', function (originVal) {
  const dt = new Date(originVal)
  const year = dt.getFullYear()
  const mouth = (dt.getMonth() + 1 + '').padStart(2, '0')
  const day = (dt.getDate() + '').padStart(2, '0')
  const houer = (dt.getHours() + '').padStart(2, '0')
  const minute = (dt.getMinutes() + '').padStart(2, '0')
  const second = (dt.getSeconds() + '').padStart(2, '0')
  return `${year}-${mouth}-${day} ${houer}:${minute}:${second}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
